//
//  JGDrupCellFactory.m
//  JGExpandTableDemo2
//
//  Created by mac on 15/9/21.
//  Copyright (c) 2015年 Free. All rights reserved.
//

#import "JGDrupCellFactory.h"
#import "JGDrupDetailViewCell.h"
#import "JGDrupSectionViewCell.h"

@implementation JGDrupCellFactory

+(UITableViewCell *)tableView:(UITableView *)tableView withInfo:(NSDictionary *)infoDic
{
    static NSString *detailViewCellIden = @"DetailViewCellIdentifier";
    static NSString *sectionViewCellIden = @"SectionViewCellIdentfier";
    
    if ([[infoDic objectOrNilForKey:@"type"] isEqualToString:@"1"]) {
        //未展开状态
        JGDrupSectionViewCell *cell = [tableView dequeueReusableCellWithIdentifier:sectionViewCellIden];
        if (cell == nil) {
            cell = [[JGDrupSectionViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:sectionViewCellIden];
        }
        cell.isOpen = [[infoDic objectOrNilForKey:@"isOpen"] boolValue];
        cell.titleLabel.text = [infoDic objectOrNilForKey:@"title"];
        cell.iconImageView.image = [UIImage imageNamed:[infoDic objectOrNilForKey:@"image"]];
        
        return cell;
    } else {
        //展开状态
        JGDrupDetailViewCell *cell = [tableView dequeueReusableCellWithIdentifier:detailViewCellIden];
        if (cell == nil) {
            cell = [[JGDrupDetailViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:detailViewCellIden];
        }
        cell.infoArray = [infoDic objectOrNilForKey:@"subClothes"];
        
        return cell;
    }
}


+(CGFloat)tableViewWithInfo:(NSDictionary *)info
{
    if ([[info objectOrNilForKey:@"type"] isEqualToString:@"1"])
    {
        return 70;
    }
    else
    {
        return [JGDrupDetailViewCell tableCellHeight:[info objectOrNilForKey:@"subClothes"]];
    }
}

@end
